<?php //ver.2011 0.1 - Eugenio Ghiglia <eugenio@blux.org> - 
require('./settings.php');
require('./lib/class.db.php');
require('./lib/lib.framework.php');
require('./lib/DynamicRSS.class.php');
$db = new Db();
$db->type='mysql';
$db->error_off();

if ($db->connetti($_db_host, $_db_user, $_db_psw, $_db_name)) {
    
    $rss = new DynamicRSS();
    $rss->db($_db_host, $_db_name, $_db_user, $_db_psw);
    
    $sql="SELECT   CONCAT('Annuncio ',a.id_annuncio) as titolo,
                   REPLACE(REPLACE(REPLACE(REPLACE(a.descrizione,'[b]',''),'[/b]',''),'[u]',''),'[/u]','') as descrizione,
                   CONCAT('http://".$_SERVER['SERVER_NAME']."/annunci.html?view=',a.id_annuncio) as link,
                   MD5(id_annuncio) as guid,
                   c.descrizione_canale as categorie,
                   DATE_FORMAT(data_pubblicazione_online, '%d/%m/%Y %H:%i:%s') as datainserimento
            FROM tbl_annunci a LEFT JOIN tbl_categorie e ON a.id_categoria=e.id_categoria, tbl_canali c
            WHERE a.attivo='1'
              AND a.scaduto='0'
              AND a.id_canale=c.id_canale
              AND a.descrizione<>''
            ORDER BY a.data_pubblicazione_online DESC
            ";
    
    $rss->query($sql);
    
    $rss->feed_url("http://".$_SERVER["SERVER_NAME"]."/rss.xml");
            
    $rss->channel( array(
                "title"=>"Annunci su ".$_SERVER["SERVER_NAME"],
                "link"=>"http://".$_SERVER["SERVER_NAME"]."/",
                "description"=>"Aggiornamenti annunci su ".$_SERVER['SERVER_NAME'],
                "copyright"=>"Copyright ".date("Y")."",
                "managingEditor"=>$_notify_email
            ));
    $rss->item( array(
                "title"=>"titolo",
                "link"=>"link",
                "author"=>"nome",
                "description"=>"descrizione",
                "category"=>"categorie",
                "guid"=>"guid", // usually the same as 'link'
                "pubDate"=>"datainserimento"
            ));
    $rss->generate();
    
    $db->disconnetti();
}
?>
